#!/usr/local/bin/php
<?php
if(empty($argv[1])) $argv[1] ='' ;
switch ($argv[1])
{
    case 'start':
        start();
        break;
    case 'stop':
        stop();
        break;
    default:
        echo 'use start , stop to batch manager~';
}

function start()
{
    echo '启动nginx~', PHP_EOL;;
    system('openresty');
    echo '启动cron服务~', PHP_EOL;;
    system('/usr/sbin/cron');
    echo "启动php-fpm", PHP_EOL;;
    system('php-fpm -D ');
    echo '启动消息通知服务~', PHP_EOL;
    system('/www/msg/mobile start');
}

function stop()
{
    echo '正在停止nginx~', PHP_EOL;;
    system('openresty -s stop');
    system('killall -9 nginx');
    echo '正在停止cron服务~', PHP_EOL;;
    system('killall -9 cron');
    echo "正在停止php-fpm~", PHP_EOL;;
    system('killall php-fpm');
    echo '正在停止消息通知服务~', PHP_EOL;
    system('/www/msg/mobile stop');
}
